<div id="layui2_here"></div>
<form class="layui-form layui-form-pane" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">长输入框</label>
    <div class="layui-input-block">
      <input type="text" name="title" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">日期选择</label>
      <div class="layui-input-block">
        <input type="text" name="date" id="date1" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">行内表单</label>
      <div class="layui-input-inline">
        <input type="text" name="number" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码框</label>
    <div class="layui-input-inline">
      <input type="password" name="password" placeholder="请输入" lay-verify="required" autocomplete="off"
        class="layui-input">
    </div>
    <div class="layui-form-mid layui-text-em">请务必填写用户名</div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">范围</label>
      <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="price_min" placeholder="￥" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-form-mid">-</div>
      <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="price_max" placeholder="￥" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">选择框</label>
    <div class="layui-input-inline">
      <select name="interest" lay-filter="aihao">
        <option value=""></option>
        <option value="0">写作</option>
        <option value="1" selected>阅读</option>
        <option value="2">游戏</option>
        <option value="3">音乐</option>
        <option value="4">旅行</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item" pane>
    <label class="layui-form-label">开关-默认开</label>
    <div class="layui-input-block">
      <input type="checkbox" checked name="open" lay-skin="switch" lay-filter="switchTest" title="开关">
    </div>
  </div>
  <div class="layui-form-item" pane>
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男" checked>
      <input type="radio" name="sex" value="女" title="女">
      <input type="radio" name="sex" value="禁" title="禁用" disabled>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">文本域</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <button class="layui-btn" lay-submit lay-filter="demo2">确认</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  </div>
</form>
<div class="layui-row">
  <div class="layui-col-xs12">
    <table class='layui-hide' id='layui2_table_here'></table>
  </div>
</div>
<script>
  function renderAll() {
    layui.use(['laytpl', 'form', 'layer'], function () {
      var form = layui.form;
      var layer = layui.layer;
      var table = layui.table;
      // 提交事件
      form.on('submit(demo2)', function (data) {
        var field = data.field; // 获取表单字段值
        // 显示填写结果，仅作演示用
        layer.alert(JSON.stringify(field), {
          title: '当前填写的字段值'
        });
        // 此处可执行 Ajax 等操作
        // …
        return false; // 阻止默认 form 跳转
      });

      // 已知数据渲染
      var inst = table.render({
        elem: '#layui2_table_here',
        cols: [[ //标题栏
          { field: 'id', title: 'ID', width: 80, sort: true },
          { field: 'username', title: '用户', width: 120 },
          { field: 'sign', title: '签名', minWidth: 160 },
          { field: 'sex', title: '性别', width: 80 },
          { field: 'city', title: '城市', width: 100 },
          { field: 'experience', title: '积分', width: 80, sort: true }
        ]],
        data: [{ // 赋值已知数据
          "id": "10001",
          "username": "张三1",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "116"
        }, {
          "id": "10002",
          "username": "张三2",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "12",
        }, {
          "id": "10003",
          "username": "张三3",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "65"
        }, {
          "id": "10004",
          "username": "张三4",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "777"
        }, {
          "id": "10005",
          "username": "张三5",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "86"
        }, {
          "id": "10006",
          "username": "张三6",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "12"
        }, {
          "id": "10007",
          "username": "张三7",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "16"
        }, {
          "id": "10008",
          "username": "张三8",
          "sex": "男",
          "city": "浙江杭州",
          "sign": "人生恰似一场修行",
          "experience": "106"
        }],
        //skin: 'line', // 表格风格
        //even: true,
        page: true, // 是否显示分页
        limits: [5, 10, 15],
        limit: 5 // 每页默认显示的数量
      });
    })
  }
</script>